//
//  ICMInputAreaView.m
//  ICrEAM
//
//  Created by rainimute on 16/12/8.
//  Copyright © 2016年 mac. All rights reserved.
//

#import "ICMInputAreaView.h"
#import "ICMTitleTextFeildView.h"

@interface ICMInputAreaView ()<ICMTitleTextFeildViewDelegate>

@end

@implementation ICMInputAreaView

- (instancetype)init{
    if (self = [super init]) {
        self.frame = CGRectMake(0, 0, ScreenWidth, ScreenHeight);
        self.backgroundColor = [UIColor colorWithWhite:0 alpha:0.5];
        UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(tapAction)];
        tap.numberOfTapsRequired = 1;
        tap.numberOfTouchesRequired = 1;
        [self addGestureRecognizer:tap];
        UIView *whiteView = [[UIView alloc]initWithFrame:CGRectMake((ScreenWidth-300)/2, ActualHeight(25)+64, ActualWidth(300), ActualHeight(260))];
        whiteView.backgroundColor = [UIColor whiteColor];
        CornerRadius(whiteView, 4);
        self.inputAreaTextView = [ICMTitleTextFeildView createEditableICMTitleTextFeildViewWithFrame:CGRectMake((ActualWidth(300)-ActualWidth(150))/2, ActualHeight(25)+64, ActualWidth(150), ActualHeight(63)) title:@"输入其他车牌号前缀"];
        self.inputAreaTextView.isUppercase = YES;
        self.inputAreaTextView.delegate = self;
//        self.inputAreaTextView.limitedNum = 2;
        [whiteView addSubview:self.inputAreaTextView];
        [self addSubview:whiteView];
    }
    return self;
}

- (void)tapAction{
    [self editableViewDidEndEdit:self.inputAreaTextView];
}

- (void)editableViewDidEndEdit:(ICMTitleTextFeildView *)sender{
    if ([self.delegate respondsToSelector:@selector(inputAreaViewWillDisappearWithText:)]) {
        [self.delegate inputAreaViewWillDisappearWithText:self.inputAreaTextView.contentText];
    }
    [self removeFromSuperview];
}

+ (instancetype)createInputAreaView{
    return [[ICMInputAreaView alloc]init];
}


@end
